package com.sh.springbootinit.controller;

import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sh.springbootinit.common.BaseResponse;
import com.sh.springbootinit.common.ErrorCode;
import com.sh.springbootinit.common.ResultUtils;
import com.sh.springbootinit.constant.FileConstant;
import com.sh.springbootinit.exception.BusinessException;
import com.sh.springbootinit.model.dto.Picture.PictureQueryRequest;
import com.sh.springbootinit.model.dto.file.UploadFileRequest;
import com.sh.springbootinit.model.dto.search.SearchRequest;
import com.sh.springbootinit.model.entity.User;
import com.sh.springbootinit.model.entity.movie.Movie;
import com.sh.springbootinit.model.enums.FileUploadBizEnum;
import com.sh.springbootinit.service.MovieService;
import com.sh.springbootinit.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * 电影接口
 */
@RestController
@RequestMapping("/movie")
@Slf4j
public class MovieController {

    @Resource
    private MovieService movieService;


    /**
     * 电影查找
     *
     * @return
     */
    @PostMapping("/list/page")
    public BaseResponse<Page<Movie>> uploadFile(@RequestBody SearchRequest searchRequest, HttpServletRequest request) throws IOException {
        List<Movie> list = movieService.searchMovie(searchRequest.getSearchText());
        Page<Movie> moviePage = new Page<>();
        moviePage.setRecords(list);
        return ResultUtils.success(moviePage);
    }


}
